import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;

@Controller
public class RegisterController {

    // 显示注册页面
    @GetMapping("/register")
    public String showRegisterForm() {
        return "register";
    }

    // 处理表单提交
    @PostMapping("/register")
    public String handleRegistration(
            @RequestParam("fullName") String fullName,
            @RequestParam("email") String email,
            @RequestParam("password") String password,
            @RequestParam("birthday") String birthday,
            @RequestParam("gender") String gender,
            @RequestParam("profession") String profession,
            @RequestParam(value = "married", defaultValue = "false") boolean married,
            @RequestParam("note") String note) {
        // 在这里处理接收到的表单数据，例如保存到数据库
        System.out.println("姓名: " + fullName);
        System.out.println("邮箱: " + email);
        System.out.println("密码: " + password);
        System.out.println("生日: " + birthday);
        System.out.println("性别: " + gender);
        System.out.println("职业: " + profession);
        System.out.println("已婚: " + married);
        System.out.println("备注: " + note);

        return "redirect:/success"; // 重定向到成功页面
    }
}